#!/usr/bin/env python
"""
Nagios plugin that monitors SGAS service on a NorduGrid ARC CE
"""

__author__="Placi Flury grid@switch.ch"
__copyright__ = "Copyright 2010, SMSCG an AAA/SWITCH project"
__date__="22.11.2010"
__version__="0.1.0"

import sys
from nagios_plugin import NagiosPluginBasic,LocalService


class GridFtp(NagiosPluginBasic):
    """
    Checks whether SGAS service is running.
    """
    def __init__(self):
        parser = NagiosPluginBasic.getOptions(self)
        parser.remove_option("-c")   # removing thresholds
        parser.remove_option("-w")
        parser.remove_option("-H")   # remove hostname option
        parser.parse_args()


    def main(self):

        service = LocalService("sgas")
        msg, return_code = service.getstate()

        print msg
        sys.exit(return_code)


if __name__ =="__main__":
    g = GridFtp()
    g.main()
